package ooday04;

/** 测试类 */
public class Test {
    public static void main(String[] args) {

        Animal[] animals = new Animal[5];
        animals[0] = new Dog("铁蛋", 2, "金");
        animals[1] = new Dog("高启强", 3, "白");
        animals[2] = new Fish("高启盛", 1, "金");
        animals[3] = new Fish("安欣", 2, "花");
        animals[4] = new Chick("老默", 3, "灰");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Chick) {
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }
            if (animals[i] instanceof Swim) {
                Swim s = (Swim) animals[i];
                s.swim();
            }
        }
    }
}